import { FormattedMessage, useIntl } from '@umijs/max';
import { Button, Modal, Radio, RadioChangeEvent, message } from 'antd';
import { Dispatch, SetStateAction, useState } from 'react';
type IParams = {
    showPayType: boolean;
    setshowPayType: Dispatch<SetStateAction<boolean>>;
    change: any;
};
const PayType: React.FC<IParams> = (props) => {
    const intl = useIntl();
    const [payType, setPayType] = useState('wxpay');
    function onChange(e: RadioChangeEvent) {
        setPayType(e.target.value);
    }
    return (
        <Modal
            width="50%"
            title={intl.formatMessage({ id: '请选择支付方式' })}
            open={props.showPayType}
            onCancel={() => {
                props.setshowPayType(false);
                message.warning('已取消');
            }}
            keyboard={false}
            maskClosable={false}
            footer={null}
            className="buyPoints"
        >
            <Radio.Group onChange={onChange} value={payType}>
                <Radio value="wxpay">
                    <FormattedMessage id="微信支付"></FormattedMessage>
                </Radio>
                <Radio value="alipay">
                    <FormattedMessage id="支付宝支付"></FormattedMessage>
                </Radio>
            </Radio.Group>

            <Button
                type="primary"
                block
                style={{ marginTop: 20 }}
                onClick={()=>{props.change(payType)}}
            >
                <FormattedMessage id="确认"></FormattedMessage>
            </Button>
        </Modal>
    );
};
export default PayType;
